<?php

namespace app\index\model;

use think\Model;
use think\Db;

class Reply extends Model
{
    public function getWeekTop()
    {
        if(cache('weekTop')){
            return cache('weekTop'); 
        }else{
            $weekTop =  Db::table('fly_reply')
            ->alias('t1')
            ->field('count(*) cn,t2.uid,t2.face,t2.nickname')
            ->join('fly_user t2','t1.uid = t2.uid')
            ->where('t1.ctime','>=',strtotime('-7 days'))
            ->group('t1.uid')
            ->order('cn desc')
            ->limit(12)
            ->select();
            cache('weekTop',$weekTop,86400);
            return $weekTop;
        }
    }
}